/**
 * 
 */
package de.cbf.cam.map2d.shapes;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

/**
 * @author Stefan Alter
 *
 */
public class Sphere extends Shape {
	protected Point middle;
	protected Integer radius;
	protected Color color = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);	
	protected int collisionFrameOffset;

	
	
//====================
//	constructors
//====================	
	/**
	 * @param position
	 */
	public Sphere(Point position,Integer radius) {
		super(position);
		this.radius = radius;
		middle = new Point(position.x+radius,position.y+radius);
	}

	/**
	 * @param x
	 * @param y
	 */
	public Sphere(int x, int y,Integer radius) {
		super(x, y);
		this.radius = radius;
		middle = new Point(position.x+radius,position.y+radius);
	}
	
//====================
//	public methods
//====================	
	@Override
	public void drawCollisionFrame(GC gc, Rectangle clientArea) {
		gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));
		gc.fillOval(position.x,position.y,radius*2+collisionFrameOffset,radius*2+collisionFrameOffset);
	}

	@Override
	public void drawObject(GC gc, Rectangle clientArea) {
		gc.setBackground(color);
		gc.fillOval(position.x,position.y,radius*2,radius*2);
	}
//====================
//	getters
//====================
	public Point getMiddle() {
		return middle;
	}

	public Integer getRadius() {
		return radius;
	}

	public Color getColor() {
		return color;
	}

	public int getCollisionFrameOffset() {
		return collisionFrameOffset;
	}
//====================
//	setters
//====================
	public void setColor(Color color) {
		this.color = color;
	}
	public void setRadius(int radius) {
		this.radius = radius;
	}
	public void setMiddle(Point middle) {
		this.middle = middle;
		//calc position values
		Point position = new Point(middle.x-radius,middle.y-radius);
		setPosition(position);
	}
	
	public void setCollisionFrameOffset(int collisionFrameOffset) {
		this.collisionFrameOffset = collisionFrameOffset;
	}
	
}
